import chainlit as cl
@cl.set_chat_profiles
async def chat_profile():
return [
cl.ChatProfile(
name="GPT-3.5",
markdown_description="The underlying LLM model is **GPT-3.5**.",
icon="https://picsum.photos/200",
),
cl.ChatProfile(
name="GPT-4",
markdown_description="The underlying LLM model is **GPT-4**.",
icon="https://picsum.photos/250",
),
]
@cl.on_chat_start
async def on_chat_start():
chat_profile = cl.user_session.get("chat_profile")
await cl.Message(
content=f"starting chat using the {chat_profile} chat profile"
).send()
from typing import Optional
import chainlit as cl
@cl.set_chat_profiles
async def chat_profile(current_user: cl.User):
if current_user.metadata["role"] != "ADMIN":
return None
return [
cl.ChatProfile(
name="GPT-3.5",
markdown_description="The underlying LLM model is **GPT-3.5**, a *175B parameter model* trained on 410GB of text data.",
),
cl.ChatProfile(
name="GPT-4",
markdown_description="The underlying LLM model is **GPT-4**, a *1.5T parameter model* trained on 3.5TB of text data.",
icon="https://picsum.photos/250",
),
cl.ChatProfile(
name="GPT-5",
markdown_description="The underlying LLM model is **GPT-5**.",
icon="https://picsum.photos/200",
),
]
@cl.password_auth_callback
def auth_callback(username: str, password: str) -> Optional[cl.User]:
if (username, password) == ("admin", "admin"):
return cl.User(identifier="admin", metadata={"role": "ADMIN"})
else:
return None
@cl.on_chat_start
async def on_chat_start():
user = cl.user_session.get("user")
chat_profile = cl.user_session.get("chat_profile")
await cl.Message(
content=f"starting chat with {user.identifier} using the {chat_profile} chat profile"
).send()
config.toml
for specific ChatProfiles by configuring overrides
from chainlit.config import (
ChainlitConfigOverrides,
FeaturesSettings,
McpFeature,
UISettings,
)
@cl.set_chat_profiles
async def chat_profile(current_user: cl.User):
return [
cl.ChatProfile(
name="MCP Enabled",
markdown_description="Profile with **MCP features enabled**. This profile has *Model Context Protocol* support activated. [Learn more](https://example.com/mcp)",
icon="https://picsum.photos/250",
starters=starters,
config_overrides=ChainlitConfigOverrides(
ui=UISettings(name="MCP UI"),
features=FeaturesSettings(
mcp=McpFeature(
enabled=True,
stdio={"enabled": True},
sse={"enabled": True},
streamable_http={"enabled": True},
)
),
),
),
Was this page helpful?